package com.ydl.zhwc.mvpandrxjava.sample.http;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * author : Zhangwenchao
 * e-mail : zhangwch@yidianling.com
 * time   : 2017/12/21
 */

public class ApiProvider {

//    private static ApiProvider provider;

    private static ApiService apiService;

    private ApiProvider() {}

    public static ApiService getApiService() {
        if (apiService == null) {
            synchronized (ApiService.class) {
                if (apiService == null) {
                    apiService = new Retrofit.Builder()
                            .baseUrl(ApiService.BASE_URL)
                            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                            .addConverterFactory(GsonConverterFactory.create())
                            .build()
                            .create(ApiService.class);
                }
            }

        }
        return apiService;
    }

}
